package com.heavenick.core.dao.impl;

import javax.sql.DataSource;

import org.apache.ibatis.session.SqlSession;

import com.heavenick.core.dao.DaoFactory;
import com.heavenick.core.dao.DaoProxy;

public class DaoFactoryImpl implements DaoFactory {
	private SqlSession sqlSession;

	@SuppressWarnings("unchecked")
	public <T> T getDao(Class<T> daoType) {
		T t = (T)daoCache.get(daoType.getName());
		if(t == null){
			t = DaoProxy.<T>newDaoProxy(daoType, sqlSession);
			daoCache.put(daoType.getName(), t);
		}
		return t;
	}

	public SqlSession getSqlSession() {
		
		return sqlSession;
	}
	
	public void setSqlSession(SqlSession sqlSession){
		this.sqlSession = sqlSession;
	}

	public DataSource getDataSoure() {
		return null;
	}

}
